//
//  ALPS_TSearchTCell.m
//  Alps
//
//  Created by dllo on 16/6/15.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ALPS_TSearchTCell.h"

@implementation ALPS_TSearchTCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.thumbnailView = [[UIImageView alloc] init];
        [self.contentView addSubview:_thumbnailView];
        
        self.titleLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_titleLabel];
        
        self.typelabel = [[UILabel alloc] init];
        self.typelabel.font = [UIFont systemFontOfSize:13];
        self.typelabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:_typelabel];
        
    }

    return self;
}


-(void)layoutSubviews
{
    [super layoutSubviews];
   
    
    [self.typelabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(7);
        make.right.equalTo(self.contentView).offset(-20);
        make.height.equalTo(30);
        make.width.equalTo(60);
    }];
    
}

-(void)setModel:(ALPS_SearchModel *)model
{
    
    if (model.imgPath != NULL) {
        [self.thumbnailView makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView).offset(0);
            make.left.equalTo(self.contentView).offset(10);
            make.height.equalTo(self.contentView.height);
            make.width.equalTo(self.contentView.height);
            
            [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.contentView).offset(7);
                make.left.equalTo(self.thumbnailView.right).offset(15);
                make.right.equalTo(self.contentView).offset(-90);
                make.height.equalTo(30);
            }];
        }];
        

    }
    else
    {
        [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView).offset(7);
            make.left.equalTo(self.contentView).offset(10);
            make.right.equalTo(self.contentView).offset(-60);
            make.height.equalTo(30);
        }];
    }

    
    self.typelabel.text = model.category;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
